package com.gedi.data.partition;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.Iterator;

/**
 * @Author:RenPu
 * @Date: 2020/1/19 17:44
 * @Version: 1.0
 * @description:
 */
public class PersonReduce extends Reducer<Text, LongWritable,Text, LongWritable> {


    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {

        long sum=0L;
        Iterator<LongWritable> iterator = values.iterator();
        while(iterator.hasNext()){
            sum +=iterator.next().get();
        }
        context.write(key,new LongWritable(sum));
    }
}
